﻿using BasicInformation.Domain;
using BasicInformation.ReadAPI.Application.Command.OwnerCommand;
using BasicInformation.ReadAPI.Application.Command.VehicleCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicCommon;

namespace BasicInformation.ReadAPI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class VehicleController : ControllerBase
    {
        private readonly IMediator mediator;

        public VehicleController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 货主列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Vehicle>> GetLineList([FromQuery] VehicleListCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 根据货主Id找到货主实体
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Vehicle> GetLineInfo([FromQuery] VehicleInfoCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
